﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace Emulator.GameBoy
{
    public class GameBoyRom
    {
        byte[] xRomContent;
        byte[] xRomHeaderContent;

        public byte[] RomContent { get { return xRomContent; } }

        public string RomTitle
        {
            get {
                return Encoding.ASCII.GetString(xRomContent, 0x134, 16);
            }
        }

        public byte[] NintendoLogo
        {
            get { 
                byte[] mLogo = new byte[48];
                Array.Copy(xRomContent, 0x104, mLogo, 0, 48);
                return mLogo;
                }
        }

        public byte CGBFlag
        {
            get {
                return xRomContent[0x143];
            }
        }

        public byte SGBFlag
        {
            get {
                return xRomContent[0x146];
            }
        }

        public byte CartridgeType
        {
            get {
                return xRomContent[0x147];
            }
        }

        public byte RomSize
        {
            get {
                return xRomContent[0x148];
            }
        }

        public byte RamSize
        {
            get {
                return xRomContent[0x149];
            }
        }

        public GameBoyRom(string aRomPath)
        {
            
        }

        public GameBoyRom(Stream aContentStream)
        {            
            xRomContent = new byte[aContentStream.Length];
            aContentStream.Read(xRomContent,0,xRomContent.Length);
            xRomHeaderContent = new byte[0x50];
            Array.Copy(xRomContent,0x100, xRomHeaderContent, 0, 0x50);
        }
    }
}
